package model

import (
	"gitee.com/liumou_site/logger"
	"os"
	"path"
)

// GetUrlFilePath 获取url文件绝对路径
func GetUrlFilePath(urlFile string, debug bool) string {
	if debug {
		logger.Info("urlFile: ", urlFile)
	}
	if path.IsAbs(urlFile) {
		logger.Info("urlFile is absolute path: ", urlFile)
		return urlFile
	}
	pwd, err := os.Getwd()
	if err != nil {
		logger.Error("get pwd error: ", err)
		return ""
	}
	logger.Info("urlFile is relative path: ", urlFile)
	return path.Join(pwd, urlFile)
}
